package com.sikaryofficial.auth.config;

import cn.hutool.core.text.CharSequenceUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author : qinjinyuan
 * @desc : 来源 与积分配置
 * @date : 2024/06/03 13:36
 */
@Getter
@Setter
@Configuration
@RefreshScope
@ConfigurationProperties(prefix = "hismk.auth")
public class HiSMKAuthConfig {

    /**
     * HiSMK H5默认注册用户密码
     */
    private String defaultH5Pwd;
    private String defaultSource;
    private Long defaultDeptId;
    private Long defaultRoleId;
    private Long defaultPostId;

    /**
     * 渠道商注册相关配置
     *
     */
    private String channelWorkbenchPwd;
    private Long channelDeptId;
    private Long channelRoleId;
    private Long channelPostId;
    private String channelSource;

    /**
     *  正常 source 注册都是 根据配置获取20积分；
     *  特殊来源，则进行特殊配置处理
     */
    private List<SourcePointsVO> sourcePointsList;

    public SourcePointsVO getBySource(String source) {
        return sourcePointsList.stream().filter(item -> CharSequenceUtil.equals(item.getSource(), source)).findFirst()
                .orElse(null);
    }

}
